//
// Created by 11510 on 2024/6/8.
//
#include <string.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;
using std::string;

void test0(){
    ifstream ifs("main.cpp");
    
    size_t pos = ifs.tellg();
    // cout << pos;

    ifs.seekg(3);
    pos = ifs.tellg();
    // cout << pos;

    string word;
    ifs >> word;
    cout << word <<endl;

    char *pdata = new char[101]();
    ifs.read(pdata, 50);

    cout << pdata << endl;

    delete []pdata;
    pdata = NULL;

    ifs.close();

}


void test1(){
    
    ifstream ifs("main.cpp");
    if(ifs == NULL){
        cout << "ifstream open file failed" << endl;
        return;
    }

    ifs.seekg(0, std::ios::end);
    long length = ifs.tellg();
    // cout << length << endl;

    ifs.seekg(0, std::ios::beg);
    char *pdata = new char[length + 1];

    ifs.read(pdata, length);

    std::cout << pdata << std::endl;

    delete[] pdata;
    pdata = NULL;
}


void test2(){
    /**
     * 需求：读取文件全部内容
     * 一开始就让文件游标处于结尾位置
     */

}





int main() {
    test2();
    return 0;
}